#ifndef GLWIDGET_H
#define GLWIDGET_H

#include <QGLWidget>
#include <QTimer>
#include <QTime>

const int MAX_PARTICLES(1000);

const GLfloat Color[12][3] =
{
  {1, 0.5, 0.5},
  {1, 0.75, 0.5},
  {1, 1, 0.5},
  {0.75, 1, 0.5},
  {0.5, 1, 0.5},
  {0.5, 1, 0.75},
  {0.5, 1, 1},
  {0.5, 0.75, 1},
  {0.5, 0.5, 1},
  {0.75, 0.5, 1},
  {1, 0.5, 1},
  {1, 0.5, 0.75}
};

class GLWidget : public QGLWidget
{
  Q_OBJECT

public:
  GLWidget(QWidget* parent = 0, unsigned int fps = 30);
  virtual ~GLWidget();

protected:
  virtual void initializeGL();
  virtual void resizeGL(int w, int h);
  virtual void paintGL();
  virtual void keyPressEvent(QKeyEvent *e);

  void loadGLTexture(const QString& filename, GLuint textures[3]);

signals:
  void fps(unsigned int);

private:
  QTimer mTimer;
  QTime mTime;
  unsigned int mFramesPainted;

  GLuint mTextures[1];
  double mXRot;
  double mYRot;

  struct Particle
  {
    double life;
    double fadeSpeed;

    //color
    double r;
    double g;
    double b;

    //position
    double x;
    double y;
    double z;

    //velocity
    double xdot;
    double ydot;
    double zdot;

    //gravity
    double xg;
    double yg;
    double zg;
  };

  Particle mParticles[MAX_PARTICLES];
};

#endif
